package com.example.vediodemo;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import com.example.vediodemo.bean.Song;

import java.util.ArrayList;
import java.util.List;

public class SongTools {

    SongHelper songHelper;
    SQLiteDatabase db;
    public SongTools(Context context){
        this.songHelper = new SongHelper(context);
    }

    public  void addSong(Song song){
        SQLiteDatabase db = songHelper.getWritableDatabase();
    }

    public List<Song> querysong(){
        SQLiteDatabase db = songHelper.getReadableDatabase();
        List<Song> songs = new ArrayList<>();
        Cursor cursor = db.query("songs",null,null,null,null,null,null);
        if(cursor.moveToFirst()){
            do{
                int a = cursor.getColumnIndex("mv_res");
                String mv_res = cursor.getString(a);
            }while (cursor.moveToNext());
        }
        cursor.close();
        db.close();
        return songs;
    }
    public Cursor select(String sql, String[] args){
        db = songHelper.getReadableDatabase();
        try{
            Cursor cursor = db.rawQuery(sql, args);
            return  cursor;
        }catch (Exception e){
            e.printStackTrace();
            return  null;
        }
    }

}
